var gridList;
var key ;
$(document).ready(function() {
    key = mini.get("key").getValue();
    gridList=mini.get("gridList");
    init_Data();
});

function init_Data(){
	gridList.load();
}
function search() {
    var key = mini.get("key").getValue();
    gridList.load({'sysImgconfig.key':key});
}

function onKeyEnter(e) {
    search();
}

function formatImg(e){
    return "<img src='"+getfile(e.value,'1')+"' style='border:none;max-width:250px;max-height:50px;'/>";
}

function formatOper(e){
    var row=e.record;
    return"<a class='mini-button' hideFocus='' href='javascript:void(0)' onClick='editData(\""+e.value+"\")'><span class='mini-button-text  mini-button-icon icon-edit'>修改</span></a><span class='separator'></span>" +
		  "<a class='mini-button' hideFocus='' href='javascript:void(0)' onClick='removeData(\""+e.value+"\",\""+row.imgName+"\")'><span class='mini-button-text  mini-button-icon icon-remove'>删除</span></a>";
}

function addData(){
	/**请修改url路径，从根目录开始 如：web/base/mysysUser/mysysUserEdit.html**/
	mini.open({
	    url: "base/sysImgconfig/sysImgconfigDetail.html?type=new&temp="+new Date().getUTCMilliseconds(),
	    title: "添加图片配置管理", width:1000, height:600,
	    onload: function () {
	        //给对话框传参数！
            //var iframe = this.getIFrameEl();
            //iframe.contentWindow.SetData("");
        },
        ondestroy: function (e) {
            if(e=="OK"){
                init_Data();
            }
        }
	});
}

function editData(id){
    /**请修改url路径，从根目录开始 如：web/base/mysysUser/mysysUserEdit.html**/
    mini.open({
	    url: "base/sysImgconfig/sysImgconfigDetail.html?type=edit&id="+id+"&temp="+new Date().getUTCMilliseconds(),
	    title: "修改图片配置管理", width:1000, height:600,
	    onload: function () {
		    //给对话框传参数！
		    //var iframe = this.getIFrameEl();
		    //iframe.contentWindow.SetData("");
	    },
	    ondestroy: function (e) {
	    if(e=="OK"){
		    init_Data();
		    }
	    }
    });
}
function removeData(id,title){
    mini.confirm("您确定要删除'"+title+"'吗？","删除确认", function(action){
	    if (action != "ok") {
	        return;
	    }
	    ActHttpRequest("sysImgconfig!del.do?id="+id,{},function(data){
            if(data.OK=="OK"){
                init_Data();
            }else{
                mini.alert(data.message);
            }
	    },null,null,null,'删除中。。。',true);
	});
}
